package a_File1;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

/*
    File文件的创建
 */
public class FileDemo01 {

    public static void main(String[] args) {
        //创建文件对象
        File file = new File("a.txt");
        //获取当前文件目录:D:\Idea-workspace\api_2207\a.txt
        String path = file.getAbsolutePath();
        System.out.println(path);
    }

    @Test
    public void fileTest01(){
        //创建文件对象
        File file = new File("a.txt");
        //获取当前文件目录: D:\Idea-workspace\api_2207\api_day09\a.txt
        String path = file.getAbsolutePath();
        System.out.println(path);

        //方式二:
        File file2 = new File("test/a/b.txt/c", "b.txt.txt");
        String path2 = file2.getAbsolutePath();
        System.out.println(path2);

        //方式三:
        new File(new File("demo"),"c.txt");
    }

    @Test//在本地磁盘创建文件
    public void newFileTest() throws IOException {
        File file = new File("a.txt");
        //获取文件路径
        String path = file.getAbsolutePath();
        System.out.println(path);
        //新建文件
       /* boolean newFile = file.createNewFile();
        System.out.println(newFile);*/

        String name = file.getName();
        System.out.println(name);

    }
}
